home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************************/
- /* HelpGetProc C14Calculator */
- /************************************************************************************/
- /* How to set up this Help facility: */
- /* */
- /* Help 'TEXT' resources run in sequence, beginning with number 1000. The count */
- /* is the symbol "helpCount" which is in the header file. The first 31 characters,*/
- /* followed by a carriage return, are used to build the index. A "blank" entry */
- /* is 33 characters long: 31 blanks, a carriage return, and one more blank for */
- /* the text. The character set is monaco 9. With this font, the text area is 21 */
- /* lines of 40 characters. It's easiest to create the text with an editor which */
- /* will display monaco 9, then cut and paste into ResEdit. */
- /************************************************************************************/
-
-
- #include "HelpGetProc.h"
- #ifndef __C14__
- #include "C14 Calculator.h"
- #endif
- #include "TE32K.h"
- #include "myClickLoop.h"
- #include "myActionProc.h"
- #include "Globals.h"
- #include "helpCount.h"
- #include <stdlib.h>
-
- void HelpGetSeg() {} /* for reference in "UnloadSeg()" calls */
-
- short HelpGetProc ()
- {
- Handle helpHandle;
- short HGRetCode = 0;
- div_t r; /* work area for division */
- Rect dataBounds = {0,0, 1,1};
- Point cSize = {12,200};
- short h,v;
- short j;
- long helpLong;
- ControlActionUPP myNewActionProc;
-
- myNewActionProc = NewControlActionProc((ProcPtr)myActionProc);
-
- if (windTbl[1].windPtr != 0) /* if help is already present */
- {
- SelectWindow(windTbl[1].windPtr); /* just activate the window */
- goto ENDING;
- }
-
-
- windTbl[1].windPtr = /* point to data area */
- (WindowPtr) &windTbl[1].windRec;
- if (useColor[0])
- windTbl[1].windPtr = /* get color template*/
- GetNewCWindow (130, windTbl[1].windPtr, (WindowPtr) -1);
- else
- windTbl[1].windPtr = /* get the template */
- GetNewWindow (130, windTbl[1].windPtr, (WindowPtr) -1);
-
- windTbl[1].windRec.refCon = ProcHelp; /* save window type */
- windTbl[1].windPathRefNum = 0; /* clear path ref number */
- windTbl[1].windTEChanged = FALSE; /* no data changed yet */
-
- v = qd.screenBits.bounds.bottom - 5 /* compute location */
- -(windTbl[1].windRec.port.portRect.bottom /* centered at the bottom */
- - windTbl[1].windRec.port.portRect.top);
- h = (qd.screenBits.bounds.right
- -(windTbl[1].windRec.port.portRect.right
- - windTbl[1].windRec.port.portRect.left)) * 0.5;
- MoveWindow (windTbl[1].windPtr, h, v, TRUE); /* position window on desktop */
-
- SetPort (&windTbl[1].windRec.port); /* set this as the grafPort */
- TextFont(monaco); /* choose the font... */
- TextFace(NIL); /* ... style, and.. */
- TextSize(9); /* ... size */
-
- workRect = windTbl[1].windRec.port.portRect;
- viewRect = workRect;
- viewRect.right -= 18;
- viewRect.left = viewRect.right - 255;
- viewRect.top = viewRect.bottom - 233;
- viewRect.bottom -= 2;
- destRect = viewRect;
- destRect.right -= 6;
- destRect.left += 6;
- windTbl[1].windTEH[0] =
- TENew (&destRect, &viewRect); /* create TE Record */
-
- /********************* install click loop ****************/
- //SetClikLoop ((UniversalProcPtr) myClikLoop,windTbl[1].windTEH[0]);
- /****************** end of install click loop ************/
- /* install click loop */
-
- TEAutoView (TRUE, windTbl[1].windTEH[0]); /* enable AutoScroll */
- TESetSelect (0,0, windTbl[1].windTEH[0]); /* caret to top */
-
- windTbl[1].windTEHCount = 1; /* one TE field is defined */
- windTbl[1].windTEHSub = 0; /* go to first TE area */
-
-
-
- workRect = (**windTbl[1].windTEH[0]).viewRect;
- windTbl[1].windCntlH[0] = /* get the control */
- GetNewControl (128, windTbl[1].windPtr);
- // #ifdef powerc
- SetCtlAction (windTbl[1].windCntlH[0], /* install own action */
- (ControlActionUPP) myNewActionProc);
- // #else
- // SetCtlAction (windTbl[1].windCntlH[0], myActionProc);
- // #endif
- SizeControl (windTbl[1].windCntlH[0], 16, /* size to fit window */
- workRect.bottom - workRect.top + 2);
- MoveControl (windTbl[1].windCntlH[0], /* move onto window */
- workRect.right, workRect.top - 1);
- ShowControl (windTbl[1].windCntlH[0]); /* make it visible */
-
- windTbl[1].windCntlHCount = 1; /* one Control is defined */
- windTbl[1].windCntlHSub = 0; /* go to first Control */
-
- workRect = windTbl[1].windRec.port.portRect;
- workRect.left += 4;
- workRect.right = workRect.left + 200;
- workRect.bottom -=2;
- workRect.top = workRect.bottom - 204;
-
- helpList = LNew(&workRect, &dataBounds, cSize, /* create the list */
- NIL, windTbl[1].windPtr, TRUE, FALSE, FALSE, TRUE);
- (**helpList).selFlags = lOnlyOne + lNoNilHilite; /* set flags for cursor */
-
- ShowWindow (windTbl[1].windPtr);
-
- helpCell.h = 0;
- helpCell.v = 0;
- j=0;
- LAddRow (helpCount-1, 1, helpList);
- helpHandle = (Handle) -1; /* assign non-null for loop */
- for (j=0; j<helpCount; j++) /* helpCount defined in HelpGetProc.h */
- {
- helpHandle = GetResource ('TEXT', 1000+j);
- HLock (helpHandle);
- if (helpHandle)
- {
- if ( (SizeResource(helpHandle)) > 32)
- LSetCell (*helpHandle, 31, helpCell, helpList);
- else
- LClrCell (helpCell, helpList);
- helpCell.v++;
- }
- HUnlock (helpHandle);
- ReleaseResource (helpHandle);
- }
-
- helpHandle = GetResource('TEXT', 1000); /* get "How to Use Help" TEXT */
- HLock (helpHandle);
- helpLong = SizeResource(helpHandle); /* get TEXT size */
- TESetText (*helpHandle+32, helpLong-32, windTbl[1].windTEH[0]);
- TECalText (windTbl[1].windTEH[0]);
- helpCell.v = 0;
- helpPrev = 0;
- LSetSelect (TRUE, helpCell, helpList);
- HUnlock (helpHandle);
- ReleaseResource (helpHandle);
-
- InvalRect (&windTbl[1].windRec.port.portRect); /* request redraw */
-
-
- ENDING:
- return HGRetCode;
- }
-